package org.buptsse.ui;

import java.util.LinkedList;
import java.util.List;

import org.buptsse.entity.MyItemizedOverlay;
import org.buptsse.entity.NearbyBookItem;
import org.buptsse.utils.APPConstant;

import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;

public class ShowInMapActivity extends MapActivity {

	private MapView mapView;
	private MapController mapController;
	private LinkedList<NearbyBookItem> list;
	private String myLongtitude,myLatitude;
	private Double longtitude,latitude;
	@Override
	protected void onCreate(Bundle bundle) {
		// TODO Auto-generated method stub
		Intent intent=this.getIntent();
		super.onCreate(bundle);
		list=APPConstant.list;
		myLatitude=intent.getStringExtra("myLatitude");
		myLongtitude=intent.getStringExtra("myLongtitude");
		System.out.println("longtitude:"+myLongtitude);
		System.out.println("latitude:"+myLatitude);
		longtitude=Double.parseDouble(myLongtitude)*1E6;
		latitude=Double.parseDouble(myLatitude)*1E6;
		this.setContentView(R.layout.show_in_map_layout);
		mapView=(MapView) findViewById(R.id.mapview);
		mapController=mapView.getController();
		mapView.setSatellite(true);
		mapView.setBuiltInZoomControls(true);
		GeoPoint point = new GeoPoint(latitude.intValue(),longtitude.intValue());
        mapController.setCenter(point);//显示中心
        mapController.setZoom(15);
	}

	@Override
	protected boolean isRouteDisplayed() {
		// TODO Auto-generated method stub
		return false;
	}
	
	public void addGPSLayer()
    {
        List<Overlay> mapOverlays = mapView.getOverlays();
        Drawable drawable = this.getResources().getDrawable(R.drawable.home_icon);
        MyItemizedOverlay itemizedoverlay = new MyItemizedOverlay(drawable);
       
        new OverlayItem(null, "Hello!", "I'm here!");
        //itemizedoverlay.addOverlay(GPSoverlayitem);
      
        //mapOverlays.clear();   //清除先前的图层，不然会叠加很多位置信息，当然如果想记录行程路线的话就不需要clear了
        //addSiteLayer();           //重新加入自定义的基站图层
        //mapOverlays.add(itemizedoverlay); 
    }

}
